package net.xdclass.service.impl;

import net.xdclass.manager.ProductManager;
import net.xdclass.model.ProductDO;
import net.xdclass.mapper.ProductMapper;
import net.xdclass.service.ProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.xdclass.util.CommonUtil;
import net.xdclass.vo.ProductVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 二当家小D
 * @since 2025-09-19
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> implements ProductService {
   @Autowired
   private ProductManager productManager;

	@Override
	public List list() {
		List<ProductDO>list = productManager.list();
		List<ProductVO> voList= new ArrayList<>();

		for(ProductDO productDO:list){
			ProductVO productVO = new ProductVO();
			BeanUtils.copyProperties(productDO,productVO);
			voList.add(productVO);
		}

		return voList;
	}

	@Override
	public ProductVO detail(Long product_id) {
		ProductDO productDO = productManager.detail(product_id);
		ProductVO productVO = new ProductVO();
		BeanUtils.copyProperties(productDO,productVO);
		return productVO;
	}
}
